#include "stdafx.h"
#include "../Inc/matrix.h"
#include <math.h>

void createIdentity(mlMatrix4X4& mat)
{
	mat[0] = 1, mat[1] = 0, mat[2] = 0, mat[3] = 0;
	mat[4] = 0, mat[5] = 1, mat[6] = 0, mat[7] = 0;
    mat[8] = 0, mat[9] = 0, mat[10] = 1, mat[11] = 0;
	mat[12] = 0, mat[13] = 0, mat[14] = 0, mat[15] = 1;
}

void createTranslateMatrix(mlMatrix4X4& mat, float x, float y, float z)
{
	mat[0] = 1, mat[1] = 0, mat[2] = 0, mat[3] = 0;
	mat[4] = 0, mat[5] = 1, mat[6] = 0, mat[7] = 0;
	mat[8] = 0, mat[9] = 0, mat[10] = 1, mat[11] = 0;
	mat[12] = x, mat[13] = y, mat[14] = z, mat[15] = 1;
}

void createRotateAxisXMatrix(mlMatrix4X4& mat, float angle)
{
	float sinAngle = sinf(angle);
	float cosAngle = cosf(angle);
	mat[0] = 1, mat[1] = 0, mat[2] = 0, mat[3] = 0;
	mat[4] = 0, mat[5] = cosAngle, mat[6] = sinAngle, mat[7] = 0;
	mat[8] = 0, mat[9] = -sinAngle, mat[10] = cosAngle, mat[11] = 0;
	mat[12] = 0, mat[13] = 0, mat[14] = 0, mat[15] = 1;
}

void createRotateAxisYMatrix(mlMatrix4X4& mat, float angle)
{
	float sinAngle = sinf(angle);
	float cosAngle = cosf(angle);
	mat[0] = cosAngle, mat[1] = 0, mat[2] = -sinAngle, mat[3] = 0;
	mat[4] = 0, mat[5] = 1, mat[6] = 0, mat[7] = 0;
	mat[8] = sinAngle, mat[9] = 0, mat[10] = cosAngle, mat[11] = 0;
	mat[12] = 0, mat[13] = 0, mat[14] = 0, mat[15] = 1;
}

void createRotateAxisZMatrix(mlMatrix4X4& mat, float angle)
{
	float sinAngle = sinf(angle);
	float cosAngle = cosf(angle); 
	mat[0] = cosAngle, mat[1] = sinAngle, mat[2] = 0, mat[3] = 0;
	mat[4] = -sinAngle, mat[5] = cosAngle, mat[6] = 0, mat[7] = 0;
	mat[8] = 0, mat[9] = 0, mat[10] = 1, mat[11] = 0;
	mat[12] = 0, mat[13] = 0, mat[14] = 0, mat[15] = 1;
}


